 var these,url,headers;
 function search(e) {
  console.log(e)
  var mainId = e.currentTarget.dataset.mainid;
  var thirdId = e.currentTarget.dataset.thirdid;
  var name = e.currentTarget.dataset.city;
  wx.navigateTo({
    url: '../../pages/list/list?mainId=' + mainId + '&thirdId=' + thirdId + '&name=' + name + '',
  })
  // Router.navto({
  //   url:"../../pages/list/list",
  //   data:{
  //     city:e.target.dataset.city,
  //     page:"目的地"
  //   }
  // })
}
function select(e) {
  var destination = this.data.destination;
  var dmainId = destination.bdata[e.target.dataset.i].id
  destination.mainId = dmainId;
  destination.idx = e.target.dataset.i;
  this.setData({
    destination: destination
  })

  this.showRight(dmainId)
}
function showRight(mainId) {
  var destination = these.data.destination;
  let that = these
  wx.request({
    url: url + 'api/get_destination_list',
    header: headers,
    data: {
      "main_type_id": mainId
    },
    success: function (data) {
      if (data.data.result === 1) {
        destination.rightList = data.data.data
        that.setData({
          destination: destination
        })
      } else {
        wx.showModal({
          title: '来自伴行的提示',
          content: data.data.message,
        })
      }

    }
  })
}
function Load(their,headers,url) {
  headers=headers;
  url=url;
  these=their;
  console.log(their.data.destination)
  var that = their;
  
  let mainId;
  var destination = their.data.destination
  try {
    var value = JSON.parse(wx.getStorageSync('mainPlace'));
    destination.bdata = value
    if (value) {
      // Do something with return value

      that.setData({

        destination: destination
      })
    }
  } catch (e) {
    // Do something when catch error
  };

  mainId = destination.bdata[0].id;

  showRight(mainId)
}
module.exports={
  Load: Load,
  showRight: showRight,
  select: select,
  search: search
}

























































